package com.study.spmongodb;

import org.joda.time.DateTime;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;

/**
 * @author study
 * @version 1.0
 * @date 2020/10/13 10:45
 */
public class JodaDate {
    public static void main(String[] args) {
        convert();
    }

    /**
     * JDK Date和 Joda转换
     */
    private static void convert() {
        Date date = new Date();
        DateTime dateTime = new DateTime(date);
        // 计算完转换成jdk 对象
        Date date2 = dateTime.toDate();
        System.out.println(dateTime);
        //
        // System.out.println(date2);
        // System.out.println(new DateTime());
        //
        // //获取零点
        // final DateTime dateTime1 = dateTime.withMillisOfDay(0);
        // System.out.println(dateTime1);
        //
        // final LocalDate min = LocalDate.MIN;
        // System.out.println(min);

        //一天最后时点|2020-10-13T23:59:59.999+08:00
        final DateTime dateTime2 = dateTime.withMillisOfDay(-1);

        System.out.println(dateTime2);
    }
}
